package com.tencent.wxcloudrun.controller;

import javax.annotation.Resource;

import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.tencent.wxcloudrun.config.ApiResponse;
import com.tencent.wxcloudrun.manager.OrderManager;
import com.tencent.wxcloudrun.vo.request.order.*;
import com.tencent.wxcloudrun.vo.response.order.*;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import jakarta.validation.Valid;
import lombok.extern.slf4j.Slf4j;

/**
 * @Author ZhaoZiYin
 * @Date 2025/2/20
 * @Description 订单控制器
 */
@Api(tags = "订单控制器")
@Slf4j
@RestController
@Validated
@RequestMapping("/api/order")
public class OrderController {

    @Resource
    private OrderManager orderManager;

    @ApiOperation("保存订单")
    @PostMapping(value = "/save")
    public ApiResponse<OrderSaveResVo> save(@RequestBody @Valid OrderSaveReqVo reqVo) {
        return ApiResponse.ok(orderManager.save(reqVo));
    }

    @ApiOperation("提交订单")
    @PostMapping(value = "/submit")
    public ApiResponse<OrderSubmitResVo> submit(@RequestBody @Valid OrderSubmitReqVo reqVo) {
        return ApiResponse.ok(orderManager.submit(reqVo));
    }

    @ApiOperation("支付订单")
    @PostMapping(value = "/pay")
    public ApiResponse<OrderPayResVo> pay(@RequestBody @Valid OrderPayReqVo reqVo) {
        return ApiResponse.ok(orderManager.pay(reqVo));
    }

    @ApiOperation("发货订单")
    @PostMapping(value = "/ship")
    public ApiResponse<OrderShipResVo> ship(@RequestBody @Valid OrderShipReqVo reqVo) {
        return ApiResponse.ok(orderManager.ship(reqVo));
    }

    @ApiOperation("收货订单")
    @PostMapping(value = "/receive")
    public ApiResponse<OrderReceiveResVo> receive(@RequestBody @Valid OrderReceiveReqVo reqVo) {
        return ApiResponse.ok(orderManager.receive(reqVo));
    }

    @ApiOperation("取消订单")
    @PostMapping(value = "/cancel")
    public ApiResponse<OrderCancelResVo> cancel(@RequestBody @Valid OrderCancelReqVo reqVo) {
        return ApiResponse.ok(orderManager.cancel(reqVo));
    }

}
